<%@page contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
<%@include file="../common/taglib.jsp"%>

<script type="text/javascript">
	function inject(obj){
		$('#receiveName').val(obj.receiveName);
		$('#fullAddress').val(obj.fullAddress);
		$('#postalCode').val(obj.postalCode);
		$('#mobile').val(obj.mobile);
	}
	
	function html(jsonObj){
		var html='<div class="set_address address_type2" id="addressFrame">';
		html+='<table width="100%" class="module_my_tblist" id="headtable" style="display: none;">';
		html+='<colgroup><col width="87%"><col width="13%"></colgroup></table>';
		html+='<ul class="list_address">';
		for(var i=0;i<jsonObj.length;i++){
			if(i<3){
				html+='<li for="addressCheckList_'+i+'">';
				html+='<label for="addressCheckList_'+i+'">';
				if(i==0){
					html+='<input type="radio" checked onclick="inject(jsonObj['+i+']);" name="addressCheckList" style="display:" class="radio"/>';
				}else{
					html+='<input type="radio" onclick="inject(jsonObj['+i+']);" name="addressCheckList" style="display:" class="radio"/>';
				}
				html+=jsonObj[i].fullAddress+'<br> ，收货人：'+jsonObj[i].receiveName+'，联系电话：'+jsonObj[i].mobile+'，邮编：'+jsonObj[i].postalCode;
				html+='</label></li>';
			}
		}
		html+='</ul></div>';
		return html;
	}
	function load(url){
		$.ajax({
			url:url, //后台处理程序
			async:true,//同步,不写默认异步async:true,
			type:'get',//数据发送方式
			dataType:'text',//接收数据格式，json格式：dataType:'json'
			//data:params,//要传递的数据，如：params={param1:"xxx"}
			cache:false,
			success:succCallback
		});
	}
	var jsonObj=null;
	function succCallback(responseText){
		jsonObj=eval(responseText);
		inject(jsonObj[0]);
		document.getElementById('addressList').innerHTML=html(jsonObj);
		document.getElementById('addressListDataLoading').style.display='none';
	}
	
</script>


<div class="shop_cart_wrap">
		<div class="shop_cart">
		<div id="addrArea" style="display:">
		<p class="hint">
			<strong>填写或选择收货地址</strong>
		</p>
		<div style="position:relative;">
			<div style="position: absolute; top: 30px; width: 100%; z-index: 10; display: block;"
				id="addressListDataLoading">
				<div style="margin: 0pt auto; padding:10px; width: 180px;border:1px solid #8CC0E7; background-color:white;"
					class="loading">
					<img align="absmiddle" style="mrgin-right:20px;"
						src="../images/icon_load.gif"><strong>加载中，请稍候...</strong>
				</div>
			</div>
			<div id="addressList">
			</div>
			</div>
			</div>
		</div>
		</div>
		<script type="text/javascript">
			load('address.action');
		</script>